﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "AddUser" in code, svc and config file together.
public class AddUser : IAddUser
{
    public void AddNewUser(string username, string pass, string email, string name, string sex, DateTime birthday, string address, string country)
    {
        try
        {
            DataClassesDataContext db = new DataClassesDataContext();
            User_Table item = new User_Table();
            item.UserID = Guid.NewGuid();
            item.Username = username;
            item.Password = pass;
            item.Name = name;
            item.Sex = sex;
            item.Birthday = birthday;
            item.Address = address;
            item.Country = country;
            item.Email = email;
            item.Score = 0;
            item.Permission = false;
            item.User_status = true;

            db.User_Tables.InsertOnSubmit(item);
            db.SubmitChanges();
        }
        catch (SqlException ex)
        {
            // Handle more specific SqlException exception here.
        }
        catch (Exception ex)
        {
            // Handle generic ones here.
        }
    }
}
